/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#include "lnmline.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int main(int argc, char *argv[]){
		lnm::TLineMap map;
	
		char *filename;
		if(argc>1) filename = argv[1];
		else{
			fprintf(stderr,"\n Usage ./xyzCadMapParser filename\n");
		}
		
	
		map.readMapFileXYZ(filename,1.0/1000.0);
	  FILE *f = fopen("output.txt","wt");
		
		
		fprintf(stderr,"SAVING to file 'output.txt' and 'output.xml'\n");
		for(int i=0;i<map.NumOfLines;i++){
			map.Lines[i].y1 = map.Lines[i].y1-500;
			map.Lines[i].y2 = map.Lines[i].y2-500;
			fprintf(f,"%f %f %f %f\n",map.Lines[i].x1,map.Lines[i].y1,map.Lines[i].x2,map.Lines[i].y2);
		}
		fclose(f);
		
		map.saveXML("output.xml","walls", "wall");

	return 0;
}
